namespace Digitalmes.Application.Mes;

/// <summary>
/// 工艺路线项明细表
/// </summary>
public sealed class ProcRoutingItemDto : Dto
{
    /// <summary>
    /// 工艺路线Id
    /// </summary>
    public long RoutingId { get; set; }

    /// <summary>
    /// 工艺路线编号
    /// </summary>
    public string? RoutingCode { get; set; }

    /// <summary>
    /// 工艺路线
    /// </summary>
    public ProcRoutingDto? Routing { get; set; }

    /// <summary>
    /// 工序Id
    /// </summary>
    public long ProcessId { get; set; }

    /// <summary>
    /// 工序编号
    /// </summary>
    public string? ProcCode { get; set; }

    /// <summary>
    /// 工序
    /// </summary>
    public ProcProcessDto? Process { get; set; }

    /// <summary>
    /// 标准加工工时(秒)
    /// </summary>
    public decimal StdOpDuration { get; set; }

    /// <summary>
    /// 标准准备工时(秒)
    /// </summary>
    public decimal StdPrepDuration { get; set; }

    /// <summary>
    /// 顺序号
    /// </summary>
    public int Pos { get; set; }

    /// <summary>
    /// 校验上一工序动作
    /// </summary>
    public PolicyCheckPrevProcEnum PolicyCheckPrevProc { get; set; }

    public string? PolicyCheckPrevProcDesc => PolicyCheckPrevProc.Description();

    /// <summary>
    /// 校验生产BOM动作
    /// </summary>
    public PolicyCheckProcBomEnum PolicyCheckProcBom { get; set; }

    public string? PolicyCheckProcBomDesc => PolicyCheckProcBom.Description();

    /// <summary>
    /// 工艺校验策略。
    /// </summary>
    /// <remarks>策略数据采用 int32 位图存储，允许多个。</remarks>
    public PolicyCheckProcessEnum PolicyCheckProcess { get; set; }

    /// <summary>
    /// 工艺校验策略拆解，取得已选取的值。
    /// </summary>
    public object PolicyCheckProcessChecked => 
        PolicyCheckProcess.SplitEnum().Select(s => new { label = s.Description(), value = (int)s });

    /// <summary>
    /// 工艺管控属性
    /// </summary>
    public ProcCtlAttrEnum CtlAttr { get; set; }

    public string? CtlAttrDesc => CtlAttr.Description();

    /// <summary>
    /// 是否禁用
    /// </summary>
    public bool IsDisabled { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreateTime { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    public string? CreateUser { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    public string? UpdateUser { get; set; }
}
